nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

javascript/Event Loop and Runtime

The mechanism that lets a single-threaded language never actually block.

10 QuestionsExpertHigh Priority ~14 min read

JavaScript runs on a single call stack, but it doesn't block waiting for slow things like network requests or timers, because the language itself never handles them — the runtime environment (a browser or Node.js) does. When you call setTimeout or fetch, the runtime takes over that work outside the JS engine, and once it's done, the corresponding callback is queued up to run later. The event loop's entire job is to check: is the call stack empty? If so, pull the next queued piece of work and run it.

What confuses most people is that the queue isn't singular. Promise callbacks land in the microtask queue, which the event loop always drains completely before touching the macrotask queue that setTimeout, setInterval, and I/O callbacks live in. That ordering — call stack, then all microtasks, then one macrotask, repeat — is why a Promise.resolve().then() reliably fires before a setTimeout(fn, 0), even though both look 'immediate' on paper.

What you'll walk away knowing

How the call stack, callback queue, and microtask queue relate, and why the event loop checks them in that order
Why Promise callbacks always run before setTimeout callbacks, even at a 0ms delay
What the runtime (browser/Node) actually contributes that the JS engine itself doesn't
How starvation can happen when microtasks keep queuing more microtasks, and why that matters for real code
1What is the difference between setTimeout(fn, 0) and Promise.resolve().then(fn)?Intermediate2How does the JS Engine interact with the Web APIs/Libuv?Intermediate3How does async/await interact with the event loop?Intermediate4What is the difference between microtasks and macrotasks?Intermediate
All Topics
1
Basics
Data Types
Functions
Objects
2
Engine
JIT
V8
Event Loop and Runtime
Concurrency and Threading
Bytecode and Parsing
Execution Context
Garbage Collector
3
this
Call Apply Bind
Closure
Error Handling
4
String Operations
Array Operations
Iterator and Generator
Modules
5
Events
Promises
Web Workers
Web Sockets
6
Functional Programming
Currying
Higher Order Functions
Memoisation
7
ES6 Classes
ES6
PWA
Web Assembly
Browser APIS
8
Security
Code
Polyfills
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.